<?php


namespace app\common\model\mysql;





class SpecsValue extends BaseModel
{
    //自动写入时间
    protected $autoWriteTimestamp = true;

    //获取规格属性
    public function getNormalBySpecsId($specsId, $field = "*")
    {
        $where = [
            "specs_id" => $specsId,
            "status" => config("status.mysql.table_normal"),
        ];

        $res = $this->where($where)
            ->field($field)
            ->select();
        return $res;
    }

    /**
     * 根据主键ID 更新数据表里的数据
     * @param $id
     * @param $data
     * @return bool
     */
    public function updateById($id, $data)
    {
        $id = intval($id);
        if (empty($id) || empty($data) || !is_array($data)) {
            return false;
        }

        $where = [
            "id" => $id,
        ];

        return $this->where($where)->save($data);
    }




}